// redPacket/pages/moneyRed/moneyRed.js
const service = require('./moneyRedService.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    listData: [],
    startPage: 0,
    hasNextPage: true
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.loadData();
  },

  /**
   * 初始化数据
   */
  loadData: function () {
    let that = this;
    if (this.data.hasNextPage) {
      service.getMyRedPacketRecord(this.data.startPage, function (res) {
        that.setData({
          listData: that.data.listData.concat(res.items),
          startPage: that.data.startPage + 1,
          hasNextPage: res.hasNextPage
        });
      });
    }
  },

  /**
* 页面上拉触底事件的处理函数
*/
  onReachBottom: function () {
    this.loadData();
  },
 
})